package com.jule.robot.strategy.impl;

import JoloProtobuf.GameSvr.JoloGame;
import com.jule.robot.service.holder.FunctionIdHolder;
import com.jule.robot.service.websocket.BaseWebSocketClient;
import com.jule.robot.strategy.BaseRobotStrategry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FoldStrategry extends BaseRobotStrategry {
    private final static Logger logger = LoggerFactory.getLogger(FoldStrategry.class);

    public FoldStrategry() {
    }

    @Override
    public void doAction(BaseWebSocketClient client, int functionId, byte[] bytes) {
//        setClient(client);
        try {
            JoloGame.JoloGame_ApplyFoldAck ack = JoloGame.JoloGame_ApplyFoldAck.parseFrom(bytes);
            StringBuilder logStr = new StringBuilder();
            logStr.append("Ack_Fold Header, functionId->"+functionId+", functionName->"+ FunctionIdHolder.GetFunctionName(functionId)+", ACK Body, result->" + ack.getResult() + ", ResultMsg->" + ack.getResultMsg()
                    + ", userId->"+ack.getUserId()+", roomId->"+ack.getRoomId() +", tableId->"+ack.getTableId()+", gameOrderId->"+ack.getGameOrderId());
            if(ack.getResult() == 1){
                logStr.append(", CurrPlayScore->"+ack.getCurrPlayScore());
            }
            logger.debug(logStr.toString());
        }catch (Exception ex){
            logger.error("Ack_Fold User error, msg = "+ex.getMessage(), ex);
        }
    }
}
